---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexTheoretical/Unconditional/Severity/PredictedValues.log
  log type:  text
 opened on:  12 Nov 2016, 21:48:18

. cd "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexTheoretical/Unconditional/Severity";
/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexTheoretical/Unconditional/Severity

. **************************************************************;
. *Author: Jeff Carter                                         *;
. *Date: Saturday, May 23, 2015                              *;
. *Purpose: Simulating Predictions                *;
. **************************************************************;
. ** Need Legend for Probabilities and Differences  **;
. use "/Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexTheoretical/Unconditional/Severity/SimData.dta";

. postutil clear;

. postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 h
> i5
>                 diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2 
>                 using PredictedValues, replace;
(note: file PredictedValues.dta not found)

. noisily display "start";
start

. local a=0 ;

. while `a' < .1 { ;
  2. {;
  3. scalar h_Accountable =   0  ;
  4. scalar h_LameDuck= 1  ;
  5. scalar h_Civilian = 0;
  6. scalar h_Military = 1;
  7. scalar h_Constant = 1;
  8. scalar h_Parliament = 0;
  9. scalar h_CivilWar = 0;
 10. scalar h_GDPpc =  12589.35;
 11. scalar h_Growth = 3.453132;
 12. scalar h_MajorPower = 0;
 13. scalar h_Borders = 2;
 14. scalar h_Mobilization =  -.0008714 ;
 15. scalar h_Time = 5;
 16.  scalar h_Rivalry = 0;
 17. scalar h_Female = 0;
 18. scalar h_Hawkish = 0;
 19. generate x_betahat0 = MG_b1*h_Accountable
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 20. generate x_betahat1 = MG_b1* h_LameDuck
>     + MG_b2*h_Hawkish
>     + MG_b3*h_Rivalry
>     + MG_b4*h_Borders
>     + MG_b5*h_Parliament
>     + MG_b6*h_Female 
>     + MG_b7*h_Time
>     + MG_b8*(h_Time^2)
>     + MG_b9*(h_Time^3);
 21. gen prob0=  1/(1+exp(x_betahat0-MG_b10));
 22. gen prob1=   (1/(1+exp(x_betahat0-MG_b11)))  -  (1/(1+exp(x_betahat0-MG_b10)))  ;
 23. gen prob2=   1- (1/(1+exp(x_betahat0-MG_b11)));
 24. gen prob3=  1/(1+exp(x_betahat1-MG_b10));
 25. gen prob4=  (1/(1+exp(x_betahat1-MG_b11)))  -  (1/(1+exp(x_betahat1-MG_b10)))  ;
 26. gen prob5=   1- (1/(1+exp(x_betahat1-MG_b11)));
 27.         gen diff0=prob3-prob0 ;
 28. gen diff1=prob4-prob1 ;
 29. gen diff2=prob5-prob2 ;
 30.         egen probhat0=mean(prob0) ;
 31. egen probhat1=mean(prob1) ;
 32. egen probhat2=mean(prob2) ;
 33. egen probhat3=mean(prob3) ;
 34. egen probhat4=mean(prob4) ;
 35. egen probhat5=mean(prob5) ;
 36. egen diffhat0=mean(diff0) ;
 37. egen diffhat1=mean(diff1) ;
 38. egen diffhat2=mean(diff2) ;
 39. tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 prob_hat2 lo2 hi2 prob_hat3 lo3 hi3 prob_hat4 lo4 hi4 prob_hat5 lo5 hi5
>         diff_hat0 diff_lo0 diff_hi0 diff_hat1 diff_lo1 diff_hi1 diff_hat2 diff_lo2 diff_hi2;
 40.             _pctile prob0, p(2.5,97.5) ;
 41.     scalar `lo0'=r(r1) ;
 42.     scalar `hi0'=r(r2) ;
 43.     _pctile prob1, p(2.5,97.5) ;
 44.     scalar `lo1'=r(r1) ;
 45.     scalar `hi1'=r(r2) ;
 46.     _pctile prob2, p(2.5,97.5) ;
 47.     scalar `lo2'=r(r1) ;
 48.     scalar `hi2'=r(r2) ;
 49.     _pctile prob3, p(2.5,97.5) ;
 50.     scalar `lo3'=r(r1) ;
 51.     scalar `hi3'=r(r2) ;
 52.     _pctile prob4, p(2.5,97.5) ;
 53.     scalar `lo4'=r(r1) ;
 54.     scalar `hi4'=r(r2) ;
 55.     _pctile prob5, p(2.5,97.5) ;
 56.     scalar `lo5'=r(r1) ;
 57.     scalar `hi5'=r(r2) ;
 58.             _pctile diff0, p(2.5,97.5) ;
 59.     scalar `diff_lo0'= r(r1) ;
 60.     scalar `diff_hi0'=r(r2) ;
 61.     _pctile diff1, p(2.5,97.5) ;
 62.     scalar `diff_lo1'= r(r1) ;
 63.     scalar `diff_hi1'=r(r2) ;
 64.     _pctile diff2, p(2.5,97.5) ;
 65.     scalar `diff_lo2'= r(r1) ;
 66.     scalar `diff_hi2'=r(r2) ;
 67.             scalar `prob_hat0'=probhat0 ;
 68.     scalar `prob_hat1'=probhat1 ;
 69.     scalar `prob_hat2'=probhat2 ;
 70.     scalar `prob_hat3'=probhat3 ;
 71.     scalar `prob_hat4'=probhat4 ;
 72.     scalar `prob_hat5'=probhat5 ;
 73.           scalar `diff_hat0'=diffhat0 ;
 74.     scalar `diff_hat1'=diffhat1 ;
 75.     scalar `diff_hat2'=diffhat2 ;
 76.  post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`prob_hat2') (`lo2') (`hi2')
>         (`prob_hat3') (`lo3') (`hi3') (`prob_hat4') (`lo4') (`hi4') (`prob_hat5') (`lo5') (`hi5')
>         (`diff_hat0') (`diff_lo0') (`diff_hi0') (`diff_hat1') (`diff_lo1') (`diff_hi1') (`diff_hat2') (`diff_lo2') (`diff
> _hi2')
> 
> 
>     ;
 77.     } ;
 78. drop    x_betahat0 x_betahat1
>         prob0 prob1 prob2 prob3 prob4 prob5
>         diff0 diff1 diff2
>         probhat0 probhat1 probhat2 probhat3 probhat4 probhat5
>         diffhat0 diffhat1 diffhat2;
 79.     local a=`a'+ .1 ;
 80.     display "." _c ;
 81.     } ;
.
. display "" ;


.  postclose mypost ;

. use PredictedValues, clear;

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
   prob_hat0 |         1    .9515738           .   .9515738   .9515738
         lo0 |         1    .9309841           .   .9309841   .9309841
         hi0 |         1    .9670064           .   .9670064   .9670064
   prob_hat1 |         1    .0373538           .   .0373538   .0373538
         lo1 |         1    .0251729           .   .0251729   .0251729
-------------+--------------------------------------------------------
         hi1 |         1    .0534025           .   .0534025   .0534025
   prob_hat2 |         1    .0110723           .   .0110723   .0110723
         lo2 |         1    .0071327           .   .0071327   .0071327
         hi2 |         1    .0164188           .   .0164188   .0164188
   prob_hat3 |         1    .9743659           .   .9743659   .9743659
-------------+--------------------------------------------------------
         lo3 |         1    .9610456           .   .9610456   .9610456
         hi3 |         1    .9839823           .   .9839823   .9839823
   prob_hat4 |         1    .0198794           .   .0198794   .0198794
         lo4 |         1    .0123094           .   .0123094   .0123094
         hi4 |         1    .0303079           .   .0303079   .0303079
-------------+--------------------------------------------------------
   prob_hat5 |         1    .0057547           .   .0057547   .0057547
         lo5 |         1    .0034333           .   .0034333   .0034333
         hi5 |         1    .0091085           .   .0091085   .0091085
   diff_hat0 |         1     .022792           .    .022792    .022792
    diff_lo0 |         1    .0076821           .   .0076821   .0076821
-------------+--------------------------------------------------------
    diff_hi0 |         1    .0409937           .   .0409937   .0409937
   diff_hat1 |         1   -.0174744           .  -.0174744  -.0174744
    diff_lo1 |         1   -.0314914           .  -.0314914  -.0314914
    diff_hi1 |         1   -.0058161           .  -.0058161  -.0058161
   diff_hat2 |         1   -.0053176           .  -.0053176  -.0053176
-------------+--------------------------------------------------------
    diff_lo2 |         1   -.0099447           .  -.0099447  -.0099447
    diff_hi2 |         1   -.0017749           .  -.0017749  -.0017749

. saveold PredictedValues, replace;
file PredictedValues.dta saved

. log close;
      name:  <unnamed>
       log:  /Users/Jeff/Dropbox/TermLimits/Replication/Models/IndexTheoretical/Unconditional/Severity/PredictedValues.log
  log type:  text
 closed on:  12 Nov 2016, 21:48:18
---------------------------------------------------------------------------------------------------------------------------
